
/**
 * 残疾人基础信息 js
 */
var common = {};

common.paginationQuery = function(pn) {
	var keyWords = $("#searchKeyWords").val();
	var params = {};
	params.businessName = keyWords;
	params.page = pn;
	server.ajaxLoadTableList({
		url:server.url + "/servicesAgency/business/list",	// post请求url路径--必填
		params:params,
		paginationTable:'data-table',
		paginationFooter:'data-pagination',
		checkbox:false,
		columns:[{
			field:'businessName',
			title:'业务名',
			width:150
		},{
			field:'year',	
			title:'年度',
			width:80
		},{
			field:'hcAreaCode.areaName',	// 显示的字段, 支持 对象.字段 格式, 例如下面用户组
			title:'地区',	// 列名-title标题
			width:100	// 列宽, 单位为px
		},{
			field:'updatedUser.userName',
			title:'更新人',
			width:90
		},{
			field:'updateTime',
			title:'更新时间',
			width:200,
			formatter:function(value,row){
				var updateTime = '--';
				if(value != null && value > 0){
					updateTime = new Date(value).format('yyyy-MM-dd hh:mm:ss');
				}
				return updateTime;
			}
		},{
			field:'action',	// 如果此为操作按钮时, field则应写成active, 此值固定!!!
			title:'操作',
			width:100,
			formatter:function(value,row){
				// 操作按钮
				/*var operationButtons = '<div class="btn-group">';
                operationButtons += '<a class="btn btn-xs btn-azure dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">操作 <i class="fa fa-angle-down"></i></a>';
                operationButtons += '<ul class="dropdown-menu dropdown-azure">';
                //operationButtons +=  '<li><a href="javascript:server.openModalBox(\'/manage/systemSettings/business/edit/' + row.id + '/1\',\'编辑\',800);"> 进入</a></li>';
                operationButtons +=  '<li><a href="javascript:void(0);" onclick="common.chooseBusiness(\''+ row.id +'\')"> 进入</a></li>';
                operationButtons += '</ul>';
                operationButtons +=  '</div>';*/
				var operationButtons = '<div class="text-center">';
				operationButtons += '<button class="btn btn-xs btn-azure" onclick="common.chooseBusiness(\''+ row.id +'\')">进入</button>'
				operationButtons += '</div>';
				return operationButtons;
			}
		}]
	});
}

common.chooseBusiness = function(businessId){
	$.ajax({
		url: server.url + "/servicesAgency/business/entryBusiness",
		type: "POST",
		data:{
			id : businessId
		},
		dataType: "json",
		success: function(data){
			if(data.notice){
				window.location.href = server.url + data.message;
			}else{
				alert(data.message);
			}
		}
	});
}
